<?php

function gen_meta($time=0, $url=null)
{
	$return = '<meta http-equiv="refresh" content="' . $time . ';';
	if ($url != null)
	{
		$return .= ' url='.$url;
	}
	$return .= '" />';
	return($return);
}

function fix_slashes($arr = '')
{
	if(is_null($arr) || $arr == '') return null;
	if(!get_magic_quotes_gpc()) return $arr;
	return is_array($arr) ? array_map('fix_slashes', $arr) : stripslashes($arr);
}

function printr($str)
{
	ob_start();
	print_r($str);
	$str = ob_get_contents();
	ob_end_clean();
	$str = '<pre>' . $str . '</pre>';
	echo $str;
}

function vdump($str)
{
	ob_start();
	print_r($str);
	$str = ob_get_contents();
	ob_end_clean();
	$str = '<pre>' . $str . '</pre>';
	echo $str;
}

function gerror_page($page_title, $page_message)
{
	$page = <<<TMP
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">	
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>$page_title</title>
		<meta name="robots" content="noindex,nofollow" />
		<style type="text/css">
			*{padding:0; margin:0; border:0; outline:0;}
			body{background: #000; font-family:Courier New, Courier, monospace; font-size:16px; color:#65CD32;}
			#container{margin:0 auto;}
			h2{font-size:16px; text-align:center; padding:30px 0 0 0; text-transform:uppercase;}
			p{text-align:center; margin:30px 0 50px 0;}
		</style>
	</head>
	<body>
		<div id="container">
			<h2>$page_title</h2>
			<p>$page_message</p>
		</div>
	</body>
	</html>
TMP;
	echo $page;
	exit;
}

function redirect($url)
{
	header('Refresh: 0; URL=' . $url);
        $redirect = <<<TMP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="refresh" content="0; url=$url" />
            <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
            <title>redirection</title>
        </head>
        <body>
            <div style="text-align: center;">
                <p>
                    Click <a href="$url" target="_top">HERE</a> to be redirected.
                </p>
            </div>
        </body>
</html>
TMP;
        echo $redirect;
	exit;
}